package ps.client.gui.timerwindow;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import ps.server.trigger.TriggerEntry;


@SuppressWarnings("serial")
public class TimerPanel extends JPanel{
    
    private static final Font TITLE_FONT = new Font("Arial", Font.BOLD, 12);
    private static final Font TIME_FONT = new Font("Arial", Font.BOLD, 16);
    
    JLabel titleLabel = new JLabel("Stinkende Wolke (curebar)");
    JLabel timeLabel = new JLabel("");
    TimerBar timerBar = new TimerBar();
    
    TimerWindow timerWindow;
    TriggerEntry triggerEntry;
    
    public TimerPanel(TimerWindow timerWindow, TriggerEntry triggerEntry) {
        this.timerWindow = timerWindow;
        this.triggerEntry = triggerEntry;
        
        setLayout(new BorderLayout(3, 1));
        setBorder(new EmptyBorder(3, 3, 3, 3));
        setBackground(Color.BLACK);
        
        add(titleLabel, BorderLayout.NORTH);
        add(timeLabel, BorderLayout.WEST);
        add(timerBar, BorderLayout.CENTER);
        
        titleLabel.setBorder(new EmptyBorder(0, 3, 0, 3));
        
        timerBar.setTimerWarning(triggerEntry.getTimerWarning());
        
        resetTimer();
    }
    
    private void resetTimer() {
        titleLabel.setPreferredSize(new Dimension(200, 20));
        titleLabel.setForeground(Color.WHITE);
        titleLabel.setFont(TITLE_FONT);
        titleLabel.setHorizontalAlignment(JLabel.LEFT);
        
        timeLabel.setPreferredSize(new Dimension(45, 20));
        timeLabel.setHorizontalAlignment(JLabel.RIGHT);
        timeLabel.setFont(TIME_FONT);
        timeLabel.setForeground(Color.GREEN);
    }
    
    public void removeTimer() {
        timerWindow.removeTimer(this);
    }
    
    public TimerWindow getTimerWindow() {
        return timerWindow;
    }
    
    
    public JLabel getTitleLabel() {
        return titleLabel;
    }
    
    public void setTitleLabel(JLabel titleLabel) {
        this.titleLabel = titleLabel;
    }

    
    public JLabel getTimeLabel() {
        return timeLabel;
    }

    
    public void setTimeLabel(JLabel timeLabel) {
        this.timeLabel = timeLabel;
    }

    
    public TimerBar getTimerBar() {
        return timerBar;
    }

    
    public void setTimerBar(TimerBar timerBar) {
        this.timerBar = timerBar;
    }

    public TriggerEntry getTriggerEntry() {
        return triggerEntry;
    }
}
